﻿using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Markup.Xaml;
using AvaloniaApplication1.ViewModels;
using Avalonia.Media;
using Avalonia.VisualTree;

namespace AvaloniaApplication1.Views
{
    public class SignCertificateWindow : Window
    {
        private SignCertificateWindowViewModel m_SignCertificateWindowViewModel;

        public SignCertificateWindow()
        {
           
            this.InitializeComponent();
#if DEBUG
            //this.AttachDevTools();
            m_SignCertificateWindowViewModel = new SignCertificateWindowViewModel();
            this.DataContext = m_SignCertificateWindowViewModel;
            //this.Opened += SignCertificateWindow_Opened;
          
#endif
        }

      

        #region EventHandel
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }

        private void TitleMove(object sender, Avalonia.Input.PointerPressedEventArgs e)
        {
            this.BeginMoveDrag(e);
        }

        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();

        }

        /// <summary>
        /// 证书
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCertificate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //StackPanel stackPanel = this.Find<StackPanel>("TestOrientation");
                //stackPanel.Orientation = Orientation.Horizontal;
                TestSnoopWin testSnoopWin = new TestSnoopWin(this);
                testSnoopWin.Show();
                //CertificateWindow certificateWindow = new CertificateWindow();
                //certificateWindow.Show();
            }
            catch (Exception exception)
            {

            }
        }

        private void TestSnoopWin_PointerPressed(object sender, Avalonia.Input.PointerPressedEventArgs e)
        {
            Point point = e.GetPosition(sender as IVisual);
        }

      

        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCommit_Click(object sender, RoutedEventArgs e)
        {
            TextBlock txtName = this.FindControl<TextBlock>(nameof(txtName));
            //Button
            //Avalonia.Controls.Presenters.TextPresenter
        }

      

        #endregion

        private void DateBind()
        {
            try
            {
               
                TextBlock txtName= this.FindControl<TextBlock>(nameof(txtName));
                //txtName.Text = m_SignCertificateWindowViewModel.Name;
                


            }
            catch (Exception e)
            {
               //AddLog()
            }
        }

        private void SignCertificateWindow_Opened(object sender, EventArgs e)
        {
            
        }
    }
}
